<template>
  <el-col>
    <el-cascader
    style="width:100%"
    placeholder="可搜索部门"
    v-model="add"
    :options="options"
    :show-all-levels="false"
    @getCheckedNodes="true"
    :props="props"
    :size="size"
    @change="cascaderChange"
    filterable></el-cascader>
  </el-col>
</template>

<script>
import {getOrganization} from "@/api/organization"
export default {
  name:"choiceCascader",
  data(){
    return {
       options:[],
       props:{label:"name",value:"id",checkStrictly: true},
       add:"",
    }
  },
  props:["value","size"],
  mounted(){
    this.getOrganization()  
    this.add = this.value
  },
  watch:{
    value(to){
      console.log("现在值",to)
      this.add = to
    }
  },
  methods:{
    cascaderChange(e){
      this.$emit('cascaderChange',e[e.length - 1])
    },
    getOrganization(){
      getOrganization()
      .then(res=>{
        console.log(res)
        this.options = res.data
      })
      .catch(e=>{
        this.$message({
          message:e.message,
          type: 'error'
        });
      })
    }
  }
    
}
</script>

<style>

</style>